Django + Vue 快速配置开发环境(vs code) |
您所在的位置:网站首页 › Django 模板 表格固定行数 › Django + Vue 快速配置开发环境(vs code) |
创建项目的 venv 环境 启用 venv, 安装 Django 框架 pip3 install django -i https://pypi.mirrors.ustc.edu.cn/simple/ python3 -m django --version 使用 django-admin 工具创建 新的框架站点 mkdir project_test # 创建站点 cd project_test django-admin startproject site_test创建模板目录 cd site_test mkdir templates编辑页面模板, 这里填充一个基本的页面 templates/index.html app_test Vue Django添加模板目录到 site_test/settings.py 中 52 ROOT_URLCONF = 'svtest.urls' 53 54 TEMPLATES = [ 55 { 56 'BACKEND': 'django.template.backends.django.DjangoTemplates', -57 'DIRS': [], +57 'DIRS': [ "templates" ], 58 'APP_DIRS': True, 59 'OPTIONS': { 60 'context_processors': [ 61 'django.template.context_processors.debug', 62 'django.template.context_processors.request', 63 'django.contrib.auth.context_processors.auth', 64 'django.contrib.messages.context_processors.messages', 65 ], 66 }, 67 }, 68 ]继续配置 django 站点的其他基本设置 编辑 /settings.py 开放访问限制: ALLOWED_HOSTS = ['*'] 修改语言: LANGUAGE_CODE = zh-hans 修改时区: TIME_ZONE = Asia/Shanghai 测试服务启动 # 启动 django 自带的 web 服务器 cd site_test python3 manage.py runserver # 默认测试的服务运行在 回环地址的 8000 端口, 若指定 IP 和端口使用: # python3 manage.py runserver # 运行的输出: Performing system checks... System check identified no issues (0 silenced). You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. March 7, 2019 - 21:06:30 Django version 2.2.12, using settings 'site_test.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. # 浏览器打开http://127.0.0.1:8000/来查看该站点 # 可以正常访问欢迎页即可, Ctrl + C 退出服务, 准备进行下一步 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |